package com.example.combine;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * Created with IntelliJ IDEA.
 * ClassName: UnionDemp
 * Package: com.example.combine
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-07-19
 * Time: 9:55
 */

public class UnionDemo {
    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //设置并行度
        env.setParallelism(1);
        //创建两条流
        DataStreamSource<Integer> source1 = env.fromElements(1,2,3);

        DataStreamSource<Integer> source2 = env.fromElements(6, 7, 8);

        DataStreamSource<String> source3 = env.fromElements("aa", "bb", "cc");

        //合流操作
        //还可以把自己合并进去
        DataStream<Integer> union = source1.union(source1, source2);

        union.print();

        env.execute();


    }
}
